<template lang="pug">
  div
</template>

<script>
  import {loginUrl} from 'config/global.toml'

  export default {
    name: 'HelloWorld',
    data() {
      return {
        msg: 'Welcome to Your Vue.js App'
      }
    },
    mounted() {
      let _data = {
        'username': 'admin',
        'password': '123'
      }
      this.$http.request({
        method: 'POST',
        url: loginUrl,
        transformRequest: [(data) => {
          // Do whatever you want to transform the data
          let ret = ''
          for (let it in data) {
            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
          }
          return ret
        }],
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        },
        data: _data
      }).then(res => {
        console.log('[kalix]-[login.js] remoteLogin function return data is: ', res.data)
      }).catch(err => {
        console.log('err', err)
      })
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  h1, h2 {
    font-weight: normal;
  }

  ul {
    list-style-type: none;
    padding: 0;
  }

  li {
    display: inline-block;
    margin: 0 10px;
  }

  a {
    color: #42b983;
  }
</style>
